package com.mylove.basicview;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.benyanyi.basicview.progress.CircleProgress;

/**
 * @author yanyi
 * @date 2018/8/17 15:34
 * @email ben@yanyi.red
 * @overview
 */
public class MainActivity extends AppCompatActivity {
    private CircleProgress circle;

    private TextView tv;
    private TextView tv2;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        circle = findViewById(R.id.circle);
        tv = findViewById(R.id.msg);
        tv2 = findViewById(R.id.msg2);
        circle.setMinSize(1000).setMaxSize(6000)
                .isDecimal(false)
                .setNumber(6000, tv);
//        circleView = findViewById(R.id.circle);
//        circleView.setRightMsg("%").isDecimal(false);
        new Thread() {
            @Override
            public void run() {
                try {
                    while (true) {
                        mHandler.sendEmptyMessage(0x100);
                        sleep(5000);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }.start();
    }

    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            int random = (int) (Math.random() * 7000);
            tv2.setText(random + "");
            circle.setNumber(random, tv);
        }
    };
}
